package engine

import (
	"fmt"
	log "github.com/sirupsen/logrus"
	"net/http"
)

func Run(r ...*Request) {

	queue := *new([]*Request)

	for _, v := range r {
		queue = append(queue, v)
	}

	for len(queue) >= 1 {
		v := queue[0]
		queue = queue[1:]

		res, err := http.Get(v.Url)
		if nil != err {
			panic(err)
		}
		mr := UTF8Reader{R: res.Body}
		resultBytes := mr.TransReader()
		log.Info("请求的数据为%s", resultBytes)
		fmt.Printf("%p\n", v.Parser)
		request, _ := v.Parser.Parse(&resultBytes)

		for _, vv := range *request {
			queue = append(queue, vv)
		}

	}
}
